 <%@ page import="driver.dao.UserDao_u" %>
 <%@ page import="driver.service.UserService_u" %>
 <%@ page import="driver.service.UserServiceImpl_u" %>
 <%@ page import="driver.entity.User" %>
 <%@ page import="driver.entity.School" %>
 <%@ page import="driver.service.UserService_a" %>
 <%@ page import="driver.service.UserServiceImpl_a" %>
 <%@ page import="java.util.ArrayList" %>
 <%@ page import="java.util.List" %>
 <%@ page import="driver.dao.UserSumDao" %><%--
  Created by IntelliJ IDEA.
  User: LSK
  Date: 2019/10/16
  Time: 19:49
  To change this template use File | Settings | File Templates.
--%>
 <%@ page contentType="text/html;charset=UTF-8" language="java" %>
 <html>

 <head>
     <!--<base target="_blank" />-->
     <meta name="viewport" content="width=device-width, initial-scale=1">
     <link rel="stylesheet" href="bootstrap/dist/css/bootstrap.min.css">
     <title>西安学车管家</title>
     <link rel="shortcut icon" href="img/bitbug_favicon.ico">
     <link href="css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
     <link href="css/font-awesome.css?v=4.4.0" rel="stylesheet">
     <link href="css/animate.css" rel="stylesheet">
     <link rel="stylesheet" href="layui/layui/css/layui.css">
 </head>
 <style>
     body {
         margin: 0;
         padding: 0;
         background-color: rgb(241, 241, 241);
         overflow-x: hidden;
     }

     #search {
         background: #ffffff;
         box-shadow: 2px 0px 15px 1px rgb(231, 231, 231);
     }

     #search li {
         border-bottom: 1px solid rgb(255, 255, 255);
     }

     #search li:hover {
         border-bottom: 1px solid #5FB878;
     }

     #search .navbar-brand:hover,
     #search li a:hover {
         color: #5FB878;
     }

     table {
         text-align: center;
     }

     .container,
     .container-fluid {
         background: #fff;
     }

     .table3 tr,
     td,
     th {
         font-size: 30px;
     }

     .table3 tr {
         color: red;
     }

     .table2 tr,
     td,
     th {
         text-align: center;
         font-size: 13px;
     }

     #table1 {
         box-shadow: 1px 1px 20px 1px rgb(235, 235, 235);
     }

     .table1 td {
         font-size: 20px;
     }

     .table1 tr th {
         background: #4cae4c;
     }

     .table1 .row {
         background: #4cae4c;
     }

     #btn1 {
         width: 100px;
         height: 34px;
         vertical-align: middle;
         font-size: 14px;
         border-radius: 0 6px 6px 0;
         margin-bottom: 14px;
     }

     #btn1 #searchIcon {
         font-size: 14px;
     }

     #btn1:hover #searchIcon {
         font-size: 20px;
     }

     .input-group {
         margin-left: 16vw;
     }

     .part1 {}

     .layui-card {
         overflow: hidden;
         border-radius: 10px;
         border-bottom: 1px solid#4cae4c;
     }
     #div2019 p
     {
         font-size: 20px;
     }
 </style>
 <div style="display: none">
     <%

    int pages=0;
    String p=request.getParameter("page");
    if(p.equals("")||p.equals("null"))
    {
        pages=0;
    }
    else
    {
        pages=Integer.valueOf(p);
    }
    //System.out.println(pages);
%>
 </div>

 <body class="gray-bg">
     <!--导航条-->
     <nav class="navbar navbar-default " id="search">
         <div class="container">
             <!-- Brand and toggle get grouped for better mobile display -->
             <div class="navbar-header">
                 <button type="button" class="navbar-toggle collapsed" data-toggle="collapse"
                     data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
                     <span class="sr-only">Toggle navigation</span>
                     <span class="icon-bar"></span>
                     <span class="icon-bar"></span>
                     <span class="icon-bar"></span>
                 </button>
                 <a target='_blank' class="navbar-brand" href="index.jsp" data-toggle="tooltip" data-placement="bottom"
                     title="返 回 首 页">
                     <img src="asset/logoBig.png" style="width: 100px;height:38px;margin-top: -7px" alt="">
                 </a>
             </div>

             <!-- Collect the nav links, forms, and other content for toggling -->

             <div class="collapse navbar-collapse">
                 <ul class="nav navbar-nav">
                     <li><!--<a target='_blank' href="#">查看所有学员基本信息 <span class="sr-only"></span></a>--></li>
                 </ul>
             </div><!-- /.navbar-collapse -->
         </div><!-- /.container-fluid -->
     </nav>
     <!-- 内容主体 -->
     <div class="container-fluid">
         <div id="part1">
             <div class="row">
                 <div class="col-sm-9">
                     <div class="wrapper wrapper-content animated fadeInUp">
                         <div class="ibox">
                             <div class="ibox-content">
                                 <p>
                                     <!--这是中间-->
                                 </p>
                                 <div class="row">
                                     <div class="col-sm-9">
                                         <div class="ibox-content" style="width: 72vw;margin-top: 20px;">
                                             <div class="carousel slide" id="carousel1">
                                                 <div class="carousel-inner">
                                                     <div class="item active">
                                                         <img id="img1" alt="image" class="img-responsive"
                                                             src="img/new1.png">
                                                     </div>
                                                     <div class="item">
                                                         <img id="img2" alt="image" class="img-responsive"
                                                             src="img/new2.png">
                                                     </div>

                                                 </div>
                                                 <a target='_blank' data-slide="prev" href="carousel.html#carousel1"
                                                     class="left carousel-control">
                                                     <span class="icon-prev"></span>
                                                 </a>
                                                 <a target='_blank' data-slide="next" href="carousel.html#carousel1"
                                                     class="right carousel-control">
                                                     <span class="icon-next"></span>
                                                 </a>
                                             </div>
                                         </div>
                                     </div>
                                 </div>
                                 <div class="layui-col-md12"
                                     style="border: 1px solid #ccc;border-radius: 10px;overflow: hidden;margin-top: 18px">
                                     <br>
                                     <div class="layui-card">
                                         <div class="layui-card-body">
                                             <table class="table table-bordered table-hover">
                                                 <%
                                               String id=request.getParameter("user");
                                               //System.out.println(id);
                                               UserService_u service=new UserServiceImpl_u();
                                               //User user = service.select_user_info(id);
                                               School school = service.login(id);
                                               out.print("<tr>");
                                               out.print("<td><strong>驾校负责人</strong></td>");
                                               out.print("<td>"+school.getName()+"</td>");
                                               out.print("</tr>");
                                               out.print("<tr>");
                                               out.print("<td><strong>手机号码</strong></td>");
                                               out.print("<td>"+school.getPhonenum()+"</td>");
                                               out.print("</tr>");
                   
                                               out.print("<tr>");
                                               out.print("<td><strong>身份证号码</strong></td>");
                                               out.print("<td>"+school.getIdcard()+"</td>");

                                               out.print("</tr>");
                   
                                               out.print("<tr >");
                                               out.print("<td><strong>驾校名称</strong></td>");
                                               out.print("<td>"+school.getSchoolname()+"</td>");
                                               out.print("</tr>");
                                           %>
                                             </table>
                                             <%
                                           UserSumDao usersum = new UserSumDao();
                                       %>
                                         </div>
                                     </div>
                                 </div>
                                 <div class="layui-col-md12"
                                     style="border: 1px solid #ccc;border-radius: 10px;overflow: hidden;margin-top: 46px">
                                     <div class="layui-card">
                                         <br>
                                         <div class="layui-card-header">
                                             <h2>驾校后台统计信息展示</h2>
                                         </div>
                                         <div class="layui-card-body">
                                             <table class="table table-hover" id="table3" style="font-size:30px">
                                                 <thead>
                                                     <tr style="font-size:20px">
                                                         <th style="font-size:20px">本日投保统计 <i
                                                                 class="layui-icon">&#xe60a;</i></th>
                                                         <th style="font-size:20px">七日内投保统计 <i
                                                                 class="layui-icon">&#xe60a;</i></th>
                                                         <th style="font-size:20px">近一个月投保统计 <i
                                                                 class="layui-icon">&#xe60a;</i></th>
                                                         <th style="font-size:20px">所有投保统计 <i
                                                                 class="layui-icon">&#xe60a;</i></th>
                                                     </tr>
                                                 </thead>
                                                 <tbody>
                                                     <tr style="font-size:20px;color:red">
                                                         <td style="font-size:20px"><%=usersum.today(id)%></td>
                                                         <td style="font-size:20px"><%=usersum.day7(id)%></td>
                                                         <td style="font-size:20px"><%=usersum.month(id)%></td>
                                                         <td style="font-size:20px"><%=usersum.sum(id)%></td>
                                                     </tr>
                                                 </tbody>
                                             </table>
                                         </div>
                                     </div>
                                 </div>
                             </div>
                         </div>
                     </div>
                 </div>
                 <div class="col-sm-3">
                     <div class="layui-col-md12">
                         <div class="layui-card">
                             <div id="div2019" class="wrapper wrapper-content project-manager"
                                 style="height:800px;border:1px solid #ccc;border-left: 3px solid #4cae4c;padding: 10px;margin-top: 20px;overflow:hidden;border-radius: 10px;">
                                 <p>
                                     <!--这是右侧-->
                                 </p>
                                 <%
                out.print(" <div class=\"layui-card-header\"><h3 class=\"h1\">"+school.getName()+"您好:</h3></div>");
               /* out.print("     <div class="layui-card-body"><h2>"+school.getSchoolname()+"</h2>");*/

                                 %>
                                 <br/>
                              <p>您的当前星级为:<div id="test9"></div></p>
                                 <br/>
                                 <p>您将享受的权益：</p>
                              <p>便捷投保,24小时极速处理理赔。</p>
                                <p>专属服务管家、保单管理系统。</p>
                                 <p>学员八折体检和八折受理。</p>
                                 <br/>
                                 <p>您的服务管家:</p>
                                <p>029-89100636</p>
                             </div>
                         </div>
                     </div>
                 </div>
                 <div class="container">
                     <!--
    <nav class="navbar navbar-default " id="search">
        <div class="container-fluid">
             Brand and toggle get grouped for better mobile display -->
                     <!--  <div class="navbar-header">
                <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
                    <span class="sr-only"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
                <a target='_blank'  class="navbar-brand" href="index.jsp">回到主页</a>
            </div>-->
                     <%
            pageContext.setAttribute("user",request.getParameter("user"));
            %>
                     <!-- Collect the nav links, forms, and other content for toggling -->
                     <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
                         <ul class="nav navbar-nav">
                             <!-- <li><a target='_blank'  href="user.jsp?user=&page=0">保单查询 <span class="sr-only"></span></a></li>-->
                             <!--<li><a target='_blank'  href="#">理赔记录 <span class="sr-only"></span></a></li>-->
                             <!--
                    <li class="dropdown">
                        <a target='_blank'  href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Dropdown <span class="caret"></span></a>
                        <ul class="dropdown-menu">
                            <li><a target='_blank'  href="#">Action</a></li>
                            <li><a target='_blank'  href="#">Another action</a></li>
                            <li><a target='_blank'  href="#">Something else here</a></li>
                            <li role="separator" class="divider"></li>
                            <li><a target='_blank'  href="#">Separated link</a></li>
                            <li role="separator" class="divider"></li>
                            <li><a target='_blank'  href="#">One more separated link</a></li>
                        </ul>
                    </li>
                    -->
                         </ul>
                         <!--
                <form class="navbar-form navbar-left">
                    <div class="form-group">
                        <input type="text" class="form-control" placeholder="Search">
                    </div>
                    <button type="submit" class="btn btn-default">搜索功能(预留)</button>
                </form>
                -->
                         <!--
                <ul class="nav navbar-nav navbar-right">
                    <li><a target='_blank'  href="#">当前登录用户:驾校某学院</a></li>
                    <li class="dropdown">
                        <a target='_blank'  href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">用户操作 <span class="caret"></span></a>
                        <ul class="dropdown-menu">
                            <li><a target='_blank'  href="#">退出登录</a></li>
                            <li><a target='_blank'  href="#">退出登录</a></li>
                            <li><a target='_blank'  href="#">退出登录</a></li>
                        </ul>
                    </li>
                </ul>-->
                     </div><!-- /.navbar-collapse -->
                 </div><!-- /.container-fluid -->
                 </nav>
                 <div>
                     <!--该用户的所有基本信息-->
                     <table class="table table-bordered table-hover" id="table1">

                         <!--<h1>在此处展示该学员的所有个人信息</h1>-->
                         <%
             /*

             */
            /* out.print("展示用户名。从session获取");
             out.print(session.getAttribute("num"));
             out.print(session.getAttribute("id"));*/
/*
             out.print("<tr>");
             out.print("<th>保险阶段</th>");
             out.print("<th>保险金额</th>");
             out.print("</tr>");

             out.print("<tr>");
             out.print("<td>"+user.getPolicytype()+"</td>");
             out.print("<td>"+user.getPolicynum()+"</td>");
             out.print("</tr>");

             out.print("<tr>");
             out.print("<th>生效日期"+"</th>");
             out.print("<th>失效日期"+"</th>");
             out.print("</tr>");

             out.print("<tr>");
             out.print("<td>"+user.getStarttime()+"</td>");
             out.print("<td>"+user.getEndtime()+"</td>");
             out.print("</tr>");*/
         %>
                     </table>
                 </div>
             </div>
             <hr class="layui-bg-green" style="margin-top: 60px;">
             <div>

                 <div class="layui-col-md12"
                     style="border: 1px solid #ccc;border-radius: 10px;overflow: hidden;margin: 14px  auto  18px;">
                     <div class="layui-card">
                         <div class="layui-card-header">
                                     <h2 style="margin-top: 20px; ">学员列表</h2>
                             <%
                   //search
               %>
                             <div class="hr-line-dashed"></div>
                             <div class="form-group">
                                 <div class="col-sm-10">
                                     <div class="input-group">
                                         <input id="search1" type="text" class="form-control"
                                             placeholder="在此输入学员姓名/手机号/身份证号码 不支持模糊查询，需要精确输入"> <span
                                             class="input-group-btn">
                                             <!-- <button type="button" class="btn btn-primary" id="btn">搜索</button> </span>-->
                                             <!-- 按钮触发模态框 -->
                                             <button id="btn1" class="btn layui-btn layui-btn-radius btn-lg"
                                                 data-toggle="modal" data-target="#myModal">搜索 <i class="layui-icon"
                                                     id="searchIcon">&#xe615;</i></button>
                                             <!-- 模态框（Modal） -->
                                             <div class="modal fade" id="myModal" tabindex="-1" role="dialog"
                                                 aria-labelledby="myModalLabel" aria-hidden="true">
                                                 <div class="modal-dialog" style="width: 60%">
                                                     <div class="modal-content">
                                                         <div class="modal-header">
                                                             <button type="button" class="close" data-dismiss="modal"
                                                                 aria-hidden="true">&times;</button>
                                                             <h4 class="modal-title" id="myModalLabel">查询结果</h4>
                                                         </div>
                                                         <div id="div1" class="modal-body"></div>
                                                         <div class="modal-footer">
                                                             <button type="button" class="btn btn-default"
                                                                 data-dismiss="modal">关闭</button>
                                                         </div>
                                                     </div><!-- /.modal-content -->
                                                 </div><!-- /.modal -->
                                             </div>
                                         </span>
                                     </div>
                                 </div>
                             </div>
                             <br>

                             <%
           
                %>
                         </div>
                         <div class="layui-card-body">
                             <table class="table table-bordered table-hover" id="table2">
                                 <tr>
                                     <th>学员姓名</th>
                                     <th>手机号码</th>
                                     <th>身份证号码</th>
                                     <th>驾校名称</th>
                                     <th>保单号(个人凭证)</th>
                                     <th>保险类型</th>
                                     <th>投保阶段</th>
                                     <th>保险金额</th>
                                     <th>生效日期</th>
                                     <th>失效日期</th>
                                     <!--<th>删除该学员</th>-->
                                     <th>操作</th>
                                     <th>操作</th>
                                 </tr>
                                 <%
                               UserService_a service2=new UserServiceImpl_a();
                               ArrayList<User> users3 =service2.selectAlluser();
                               ArrayList<User> users=new ArrayList<User>();
                              /* for (int i = 0; i < users.size(); i++) {
                                   if(users3.get(i).getSchool_num().equals(school.getPhonenum()))
                                   {
                                       users.add(users3.get(i));
                                   }
                               }*/
                               //System.out.println(users3.size());
                                for(User user4:users3)
                                {
                                    if(user4.getSchool_num().equals(school.getPhonenum()))
                                        users.add(user4);
                                }
                               //System.out.println(users.size());
                               int sum=users.size();
                               List<User> users2;
                               if(sum<20*(pages+1))
                               users2= users.subList(20*pages,sum);
                               else
                                   users2= users.subList(20*pages,20*(pages+1));
                   
                              // users.subList();
                   
                               for(User user:users2) {
                                   out.print("<tr>");
                                   out.print("<td>" + user.getName() + "</td>");
                                   out.print("<td>" + user.getPhonenum() + "</td>");
                                   out.print("<td>" + user.getIdcardnum() + "</td>");
                                   out.print("<td>" + user.getSchool_name() + "</td>");
                                  %>

                                 <td>
                                     <a  target='_self' class="aHref1" style="color: #009688"  href="javascript:" lsk="<%=user.getId()%>"><%=user.getPolicyid()%></a></td>
                                 <!--隐藏a标签，下载专用-->
                                 <a target="_self" class="aHref2" style="display: none" href="javascript:" download="<%out.print(user.getName()+user.getPolicyid());%>.pdf"></a>


                                 <%
                                   out.print("<td>" + user.getPolicyprod() + "</td>");
                                   out.print("<td>" + user.getPolicytype() + "</td>");
                                   out.print("<td>" + user.getPolicynum() + "</td>");
                                   out.print("<td>" + user.getStarttime() + "</td>");
                                   out.print("<td>" + user.getEndtime() + "</td>");
                                   out.print("<td><a target='_blank'   style=\"color: #009688\" href=\"applyuser.jsp?num="+user.getPhonenum()+"\">查看理赔记录</a></td>");
                                   out.print("<td><a target='_blank'  style=\"color: #009688\"  href=\""+"addpayfor.jsp?phonenum="+user.getPhonenum()+"&uid="+user.getId()+"&sid="+school.getId()+"\" >发起理赔申请</a></td>");
                               }
                                   //此处用js操作吧
                   
                                   //out.print("<td><a target='_blank'  href=\""+"user.jsp?user="+user.getId()+"\">查看</a></td>");
                                   //out.print("</tr>");%>
                             </table>
                             <!--<a style="color: #009688"></a>-->
                             <nav aria-label="Page navigation">
                                 <ul class="pagination">
                                     <li>

                                     </li>

                                     <%
                                           out.print("第"+(pages+1)+"页");
                                           out.print("共"+((sum/20)+1)+"页\n<br>");
                                           int n=(sum/20)+1;
                                           for (int i = 0; i < n; i++) {
                                               out.print("<li><a target='_blank'  href=\""+"user.jsp?page="+i+"&user="+id+"\">"+(i+1)+""+"</a></li>");
                                           }
                        
                                       %>
                                     <li>
                                     </li>
                                 </ul>
                             </nav>
                         </div>
                     </div>
                 </div>

             </div>

         </div>
     </div>
     <script src="bootstrap/dist/js/jquery-3.4.1.min.js"></script>
     <script src="bootstrap/dist/js/bootstrap.min.js"></script>
     <script src="bootstrap/dist/js/layui/layui.all.js"></script>
     <script>
         /* 鼠标特效 */
         var a_idx = 0;
         jQuery(document).ready(function ($) {
             $("body").click(function (e) {
                 var a = new Array("富强", "民主", "文明", "和谐", "自由", "平等", "公正", "法治", "爱国", "敬业", "诚信",
                     "友善");
                 var $i = $("<span/>").text(a[a_idx]);
                 a_idx = (a_idx + 1) % a.length;
                 var x = e.pageX,
                     y = e.pageY;
                 $i.css({
                     "z-index": 9999999999999999999999999999999999999999,
                     "top": y - 20,
                     "left": x,
                     "position": "absolute",
                     "font-weight": "bold",
                     "color": "#ff6651"
                 });
                 $("body").append($i);
                 $i.animate({
                         "top": y - 180,
                         "opacity": 0
                     },
                     1500,
                     function () {
                         $i.remove();
                     });
             });
         });
     </script>
     <script src="Lskjs/lskjs.js" charset="utf-8"></script>
     <script>
         $("#btn1").click(function () {
             fun1();
             //$('#myModal').modal('show');
             console.log("模态框打开了");


             //alert('模态框打开了');
         });

         //处理搜索逻辑的ajax
         function fun1() {
             console.log("你点击我了");


             $.ajax({
                 url: "${pageContext.request.contextPath}/search", // 请求路径
                 type: "POST", //请求方式
                 //data: "username=jack&age=23",//请求参数
                 data: {
                     "obj": $("#search1").val(),
                     "school_id": "<%out.print(school.getPhonenum());%>"

                 },
                 success: function (data) {
                     //alert(data);
                     console.log(data);
                     $("#div1").html(data);
                 }, //响应成功后的回调函数
                 error: function () {
                     //myalter("出错啦...")
                     layui.use('layer', function () {
                         var layer = layui.layer;

                         layer.msg("数据获取异常，请重新尝试", {
                             time: 20000, //20s后自动关闭
                             btn: ['确认']
                         });
                         $('.layui-layer-msg').css('backgroundColor', 'rgba(0,150,136,0.5)');

                     });

                 }, //表示如果请求响应出现错误，会执行的回调函数

                 dataType: "html" //设置接受到的响应数据的格式
             });

         }
     </script>
     <script>
         let count = 1;
         window.setInterval(function () {

             if (count++ % 2 === 0) {
                 $("#img1").attr("src", "img/new2.png");
                 $("#img2").attr("src", "img/new1.png");
             } else {
                 $("#img2").attr("src", "img/new1.png");
                 $("#img1").attr("src", "img/new2.png");
             }
         }, 3000);
     </script>

     <script>
         //添加星星 
         layui.use(['rate'],
             function () {
                 var
                     rate =
                     layui.rate;
                 //只读
                 rate.render({
                     elem: '#test9',
                     value: 5,
                     readonly: true
                 });
             });
     </script>
 <script>
     var href1 = document.getElementsByClassName("aHref1");
     var href2=document.getElementsByClassName("aHref2");
     console.log(href1.length);
     for(let i=0;i<href1.length;i++)
     {
         href1[i].onclick=function () {
             console.log(href1[i].getAttribute("lsk"));
             $.ajax({
                 url: "${pageContext.request.contextPath}/pdf",
                 type: "POST",
                 data: {
                     "uid": href1[i].getAttribute("lsk")

                 },
                 success: function (data) {
                     console.log(i);
                     href2[i].setAttribute("href",data);
                     href2[i].click();


                 }, //响应成功后的回调函数
                 error: function () {
                     console.log("生成PDF错误，请联系管理员");
                     alert("生成PDF错误，请联系管理员");
                 }, //表示如果请求响应出现错误，会执行的回调函数
                 dataType: "text" //设置接受到的响应数据的格式
             });







         };
     }
 </script>

 </body>

 </html>